package com.reader.helper;

import android.util.ArrayMap;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * cache object of 6C tag's Operations (including writing and killing)
 *
 * @author Administrator
 */
public class OperateTagBuffer {
    /**
     * described object of 6C tag's Operations (including writing and killing)
     *
     * @author Administrator
     */
    public static class OperateTagMap {
        /**
         * PC value
         */
        public String strPC;
        /**
         * CRC value
         */
        public String strCRC;
        /**
         * EPC value
         */
        public String strEPC;
        /**
         * Data in total
         */
        public String strData;
        /**
         * Length of data
         */
        public int nDataLen;
        /**
         * Antenna ID
         */
        public byte btAntId;
        /**
         * Operating times
         */
        public int nReadCount;

        /**
         * Operations (including writing and killing)tag default constructor
         */
        public OperateTagMap() {
            strPC = "";
            strCRC = "";
            strEPC = "";
            strData = "";
            nDataLen = 0;
            btAntId = 0;
            nReadCount = 0;
        }
    }

    /**
     * Pick specific tag from the cache object
     */
    public String strAccessEpcMatch;
    /**
     * cache object
     */
    public List<OperateTagMap> lsTagList;

    /**
     * 自定义字段--key value，判断当前是否有key 如果有就不往集合中添加
     */
    public ArrayMap<String, Integer> dtIndexMap;
    /**
     * 自定义字段--速率
     */
    public volatile int nReadRate;
    /**
     * 自定义字段--开始时间
     */
    public Date dtStartTag;
    /**
     * 自定义字段--结束时间
     */
    public Date dtEndTag;

    /**
     * Operate cache of tags, including writing and killing
     */
    public OperateTagBuffer() {
        strAccessEpcMatch = "";
        lsTagList = new ArrayList<OperateTagMap>();
        dtIndexMap = new ArrayMap<>();
        nReadRate = 0;
        dtStartTag = new Date();
        dtEndTag = dtStartTag;
    }

    /**
     * Clear cache  of tags
     */
    public final void clearBuffer() {
        lsTagList.clear();
        dtIndexMap.clear();
        nReadRate = 0;
        dtStartTag = new Date();
        dtEndTag = dtStartTag;
    }
}
